<div class="runs index">
	<h2><?php __('Runs');?></h2>
	<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
			<th>&nbsp;Project</th>
			<th>&nbsp;ID</th>
			<th>&nbsp;File ID</th>
			<th>&nbsp;Batch ID</th>
			<th colspan="2">&nbsp;Blacklist</th>
			<th>&nbsp;Current Step</th>
			<th>&nbsp;Next Step</th>
			<th>&nbsp;Date</th>
			<th class="actions">&nbsp;<?php __('Actions');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($result as $r):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	
	$nextstep = $r['s']['order']+1;
	$result2 = mysql_query("SELECT statusname, step FROM statuses WHERE statuses.order = '$nextstep'");
	$row = mysql_fetch_array($result2);
	$nextname = $row["statusname"]; 
	$step= $row["step"]; 
	?>
	<tr<?php echo $class;?>>
		<td width="190">&nbsp;<?php echo $r['p']['name']; ?></td>
		<td width="50">&nbsp;<?php echo $r['r']['id']; ?></td>
		<td width="90">&nbsp;<?php echo $r['r']['fileid']; ?></td>
		<td width="90">&nbsp;<?php echo $r['r']['batchid']; ?></td>
		<td width="40">&nbsp;<?php echo $this->Batch->blacklisted($r['r']['id']);  ?></td>
		<td width="40">&nbsp;(<?php echo $this->Batch->blacklistedopen($r['r']['id']); ?>)</td>
		<td width="400">&nbsp;<?php echo $r['s']['statusname']; ?></td>
		<td width="400">&nbsp;<?php echo $nextname; ?></td>
		<td width="200">&nbsp;<?php echo $r['rhs']['date']; ?>&nbsp;</td>
		<td class="actions">
		    <?php
		    IF($nextstep == 24 || $nextstep == 25 || $nextstep == 26 ) { echo "----------"; }
		    ELSE { echo $this->Html->link(__('Continue', true), array('controller' => 'massswap', 'action' => $step, '?' => array('runid' => $r['r']['id'])), array(), 'Are you sure you want to continue?'); } ?> 
			<?php echo $this->Html->link(__('View', true), array('controller' => 'runs', 'action' => 'view2', $r['r']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
</div>